Stack-based memory allocation